package br.fbc.util;

import java.io.File;

public class Util {

	private static Configurations configurations;
		
	public static  Configurations getConfigurations(){
		
		if(null == configurations)
			configurations = new Configurations();
		
		if(null == configurations.getApiKey()){
		
			PropertiesLoaderImpl lp = new PropertiesLoaderImpl(getPath());			
			configurations.setApiKey(lp.getValor("API_KEY"));
			configurations.setSecretKey(lp.getValor("API_SECRETKEY"));
			configurations.setNomeApp(lp.getValor("nomeApp"));
			configurations.setBoasVindas(lp.getValor("boasVindas"));
			configurations.setBoasVindas2(lp.getValor("boasVindas2"));
			configurations.setImagem(lp.getValor("imagem"));
			
			
			
			if(null != lp.getValor("home"))
				configurations.setHome(new Boolean(lp.getValor("home")));
		}
		
		return configurations;
		
	}
	private static String getPath(){
		String nomeArquivoTemp = "temp.txt";
		File file = new File(nomeArquivoTemp);
		
		String path = file.getAbsolutePath().replace(nomeArquivoTemp,""); 
		System.out.println("Local onde arquivo deve estar: "+file.getAbsolutePath());
		return path;
		
	}
}
